from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from home  import models,ser

# Create your views here.
class TopNav(APIView):
    def get(self,request):
        #展示头部导航 有效的数据  排序按照sort 排序
        top=models.Nav.objects.filter(isdel=False,postion=1).order_by("sort")
        topser=ser.NavSer(top,many=True)
        return Response({"msg":"ok","data":topser.data,"code":200})

class FootNav(APIView):
    def get(self,request):
        #展示头部导航 有效的数据  排序按照sort 排序
        foot=models.Nav.objects.filter(isdel=False,postion=0).order_by("sort")
        footser=ser.NavSer(foot,many=True)
        return Response({"msg":"ok","data":footser.data,"code":200})